package graphicView;

import java.util.Observable;

import model.ClassImpl;
import model.PackageImpl;

/**
 * Team EBE - Elite Bombard Elephants
 * 
 * ActiveClassNotifier is an implementation of observable and it notifies its
 * observers of changes made to relationships and the class inspector
 * 
 */
public class ActiveClassNotifier extends Observable {
	private ClassImpl activeClass;
	private Boolean relationshipActive;
	private PackageImpl activePackage;

	public ActiveClassNotifier() {
		activeClass = null;
	}

	/**
	 * changePackage notifies the package inspector that the active package has
	 * changed
	 */
	public void changePackage(PackageImpl toChange) {
		activePackage = toChange;
		setChanged();
		notifyObservers(this.activePackage);
	}

	/**
	 * aRelationshipEndPointIsActive notifies the observers that the
	 * relationship end-point is active
	 */
	public void aRelationshipEndPointIsActive() {
		relationshipActive = true;
		setChanged();
		notifyObservers(relationshipActive);
	}

	/**
	 * deactivateRelationship notifies the observers that the relationship has
	 * been deactivated
	 */
	public void deactivateRelationship() {
		relationshipActive = false;
		setChanged();
		notifyObservers(relationshipActive);
	}

	/**
	 * changeClass changes the active class and notifies the observers of the
	 * change
	 * 
	 * @param toChange
	 *            the class that is desired to be changed to
	 */
	public void changeClass(ClassImpl toChange) {
		activeClass = toChange;
		setChanged();
		notifyObservers(this.activeClass);
	}
}
